import Vue from "vue";
import axios from "axios";
import store from "../store";

axios.interceptors.request.use((config) => {
    // 检查是否保存了登录态
    const token = store.state.user.token;
    // 如果有 token，就给它携带到 header 里面
    if (token) config.headers.token = token;
    return config;
});

Vue.prototype.$http = axios;
